/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Clases;

import java.util.LinkedList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

public class ModeloTareas  extends AbstractTableModel {
private List<Tarea> mTareas;
private String[] mColumnas = {"Titulo","Descripcion","Prioridad", "Vencimiento", "Responsable", "Categoria", "Progreso"};

 public ModeloTareas()
    {
        mTareas = new LinkedList<Tarea>();
    }

    public ModeloTareas(List<Tarea> lista)
    {
        mTareas = lista;
    }




    @Override
    public int getRowCount() {
          int wRes = 25;
        if (mTareas.size() > 25)
        {
            wRes = mTareas.size();
        }
        return wRes;
    }

    @Override
    public int getColumnCount() {
        return 7;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Object res = "";
        if (rowIndex < mTareas.size())
        {
            Tarea aux = mTareas.get(rowIndex);
            switch (columnIndex)
            {
                case 0:
                    res = aux.getTitulo();
                    break;
                case 1:
                    res = aux.getTexto();
                    break;
                case 2:
                    switch(aux.getPrioridad())
                    {
                        case 1: res = "Urgente";
                                break;
                        case 2: res = "Alta";
                                break;
                        case 3: res = "Media";
                                break;
                        case 4: res = "Baja";
                                break;
                    }
                    break;
                case 3:
                    res = aux.getVencimiento();
                    break;
                case 4:
                    res = aux.getResponsable().getApodo();
                    break;
                case 5: 
                    res = aux.getCategoria().getNombre();
                    break;
                case 6:
                    res = aux.getCompletado()+"%";
                    break;
            }
        }
        return res;
    }
@Override
    public String getColumnName(int column)
    {
        return mColumnas[column];
    }
     @Override
    public boolean isCellEditable(int rowIndex, int columnIndex)
    {
        return false;
    }
 public Tarea getItem(int pRowIndex)
    {
        Tarea wResp = null;
        if(pRowIndex < mTareas.size())
            wResp = mTareas.get(pRowIndex);
        return wResp;
    }
    
}
